<template>
	<view class="video-play">
		<image :src="videoObj.img" mode=""></image>
		
		<view class="video_tool">
			<view @click="this.muted = !this.muted" :class="['iconfont' ,muted?'iconjingyin':'iconshengyin']"></view>
			<view class="iconfont iconzhuanfa"><button type="primary" open-type="share"></button></view>
		</view>
		<view class="video_warp">
			<video :src="videoObj.video" controls objectFit="fill" :muted="muted"></video>
		</view>
		<view class="download">
			<view class="download_btn" @click="handleDowlen">
				下载高清
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				videoObj:{},
				muted: false
			};
		},
		onLoad() {
			// console.log(getApp().globalData)
			this.videoObj = getApp().globalData.video;
		},
		methods:{
			async handleDowlen(){
				await uni.showLoading({
					title:'下载中'
				})
				const {tempFilePath} = (await uni.downloadFile({
					url:this.videoObj.video
				}))[1];
				await uni.saveVideoToPhotosAlbum({
					filePath:tempFilePath
				});
				
				uni.hideLoading();
				await uni.showToast({
					title:'下载成功'
				})
			}
		}
	}
</script>

<style lang="scss">
.video-play{
	position: relative;
	image{
		position: absolute;
		width: 100vh;
		height: 100vh;
		z-index: -1;
		filter: blur(20px);
	}
	.video_tool{
		height: 80rpx;
		display: flex;
		justify-content: flex-end;
		.iconfont{
			width: 80rpx;
			color: #FFFFFF;
			font-size: 50rpx;
			border-radius: 40rpx;
			background-color: rgba(0,0,0,0.2);
			display: flex;
			align-items: center;
			justify-content: center;
			margin-right: 20rpx;
		}
		.iconshengyin{}
		.iconzhuanfa{
			position: relative;
			button{
				position: absolute;
				width: 100%;
				height: 100%;
				opacity: 0;
			}
		}
	}
	.video_warp{
		display: flex;
		justify-content: center;
		video{
			width: 360rpx;
			height: 600rpx;
		}
	}
	.download{
		margin-top: 20rpx;
		display: flex;
		justify-content: center;
		.download_btn{
			width: 360rpx;
			height: 80rpx;
			border-radius: 40rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #FFFFFF;
			border: 1rpx solid #fff;
			background-color: rgba(0,0,0,0.6);
		}
	}
}
</style>
